//
//  SpecialDetailTitleTableViewCell.m
//  BTRIP
//
//  Created by dllo on 15/11/22.
//  Copyright © 2015年 johnbk. All rights reserved.
//

#import "SpecialDetailTitleTableViewCell.h"
#import "SuitableHeight.h"
@implementation SpecialDetailTitleTableViewCell

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

-(void)dealloc{
    [_labelOfDescription release];
    [_labelOfTitle release];
    [_secondModel release];
//    [_arrayOfHeightOfDesc release];
    [super dealloc];
}
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
//        _arrayOfHeightOfDesc = [NSArray array];
        [self createView];
    }
    return self;
}
-(void)createView{
    self.labelOfTitle = [[UILabel alloc]init];
    
    
    self.labelOfDescription = [[UILabel alloc]init];
    [self.contentView addSubview:self.labelOfDescription];
//    [self.labelOfDescription release];
    self.labelOfDescription.font = [UIFont systemFontOfSize:14];
    
}
- (void)layoutSubviews{
    [super layoutSubviews];
    self.labelOfTitle.frame = CGRectMake(10 * SWIDTH, 10 * SWIDTH, KWIDTH - 20, 30 * SWIDTH);
    //self.labelOfTitle.backgroundColor = [UIColor greenColor];
    
    self.labelOfDescription.frame = CGRectMake(10 * SWIDTH, 10 + self.labelOfTitle.frame.size.height, self.labelOfTitle.frame.size.width, self.heightOfDescription);
    //self.labelOfDescription.backgroundColor = [UIColor redColor];
    self.labelOfDescription.numberOfLines = 0;
    self.labelOfDescription.lineBreakMode = NSLineBreakByWordWrapping;
    
    
}

- (void)setSecondModel:(FirstSpecialSecondModel *)secondModel{
    if (_secondModel != secondModel) {
        [_secondModel release];
        _secondModel = [secondModel retain];
    }
    if (secondModel.title.length != 0) {
        self.labelOfTitle.text = secondModel.title;
        [self.labelOfTitle setFont:[UIFont systemFontOfSize:16]];
//        NSLog(@"??%@",secondModel.title);
        [self.contentView addSubview:self.labelOfTitle];
    }else{
        self.heightOfTitle = 0;
    }
    self.labelOfDescription.text = secondModel.textDescription;
    self.labelOfDescription.numberOfLines = 0;
//    self.heightOfTitle = [SuitableHeight suitableHeight:secondModel.title andWidth:self.labelOfTitle.frame.size.width andFont:14];
    self.heightOfDescription = [SuitableHeight suitableHeight:secondModel.textDescription andWidth:self.labelOfDescription.frame.size.width andFont:14];
    
}


@end
